package stream;

import pojo.Student;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Stream;

public class StudentStream {
    public static void main(String[] args) {
        /**
         * Student sno sanme age
         * 流中有若干student对象
         * 把流中的student的age 拿出来，放到新的流中
         */

        Student stu1=new Student("101","汪云飞",22);
        Student stu2=new Student("102","周雨晴",20);
        Student stu3=new Student("103","大头",25);
        Stream<Student> stream=Stream.of(stu1,stu2,stu3);
/**
 * 里面是函数式接口
 * 对Function中的R apply(T t);
 * 进行了重写
 */
stream.sorted((a,b)->{
    return a.getAge()-b.getAge();
}).forEach(System.out::println);
//       stream.map(s-> s.getAge()).forEach(System.out::println);
    }
}
